/**
 * JAVACC DEMO 1.0
 * @copy right zbxsoft company All rights reserved. 
 * @Package com.zbxsoft.wbd.service.cacheplugins  
 */
package com.apache.bid.service.cacheplugins;

import org.apache.log4j.Logger;

import com.apache.api.manager.PluginConnector;
import com.apache.api.manager.ProxyManager;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.bid.common.BidCommonUtil;
import com.apache.bid.entity.BidItem;
import com.apache.bid.manager.BidItemManager;
import com.apache.tools.DateUtils;
import com.apache.tools.StrUtil;

/**
 * description:  手动发布标的插件
 * @author Hou Dayu 创建时间：2016-3-22  
 * @Copyright(c)2014:北京中百信软件技术有限公司
 */
public class HandStartItemPluginImpl implements PluginConnector {

	private Logger log = Logger.getLogger(getClass());
	private ProxyManager wbdProxyCacheManager;
	private BidItemManager bidItemManager;

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * @see com.zbxsoft.api.manager.PluginConnector#execute(com.zbxsoft.api.vo.ParamsVo)  
	 */
	public Object execute(ParamsVo param) throws Exception {
		ResultEntity entity = new ResultEntity();
		ParamsVo vo = new ParamsVo();
		String itemId = String.valueOf(param.getParams("itemId"));
		vo.setInfoId(itemId);
		BidItem item = (BidItem) bidItemManager.getInfoById(vo);
		String openTime = StrUtil.doNull(String.valueOf(param.getParams("openTime")),
				DateUtils.Now.fmt_yyyyMMdd_HHmmss());
		String firstBidTime = StrUtil.doNull(String.valueOf(param.getParams("firstBidTime")), BidCommonUtil
				.getInstance().getMergeTime(openTime, "3600"));
		String limitTime = String.valueOf(param.getParams("limitTime"));
		item.setOpenTimePre(openTime);
		item.setFirstBidTimePre(firstBidTime);
		item.setLimitTime(StrUtil.doNull(limitTime, item.getLimitTime()));
		vo.setObj(item);
		vo.setKey("editItem");
		entity = (ResultEntity) wbdProxyCacheManager.saveInvoke(vo);
		return entity;
	}

	public void setWbdProxyCacheManager(ProxyManager wbdProxyCacheManager) {
		this.wbdProxyCacheManager = wbdProxyCacheManager;
	}

	public void setBidItemManager(BidItemManager bidItemManager) {
		this.bidItemManager = bidItemManager;
	}

}
